package com.campus.client.controller;

import com.campus.client.net.ClientConnector;
import com.campus.client.view.TeacherMainFrame;
import com.campus.common.message.TeacherRegisterResponse;
import com.campus.common.vo.Teacher;

import javax.swing.*;
import java.awt.*;
import java.io.IOException;

public class TeacherMainController extends Component{
    private TeacherMainFrame teacherMainFrame;
    private ClientConnector connector;

    public TeacherMainController(TeacherMainFrame teacherMainFrame, ClientConnector connector) {
        this.teacherMainFrame = teacherMainFrame;
        this.connector = connector;
        setupEventHandlers();
    }

    private void setupEventHandlers() {
        // 设置登录按钮事件
        teacherMainFrame.setChangePasswordButtonAction(event -> {
            try {
                teacherMainFrame.showPasswordChangeFrame();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        });

        teacherMainFrame.setLogoutButtonAction(event -> {

            try {
                JOptionPane.showMessageDialog(this,
                        "已退出登录",
                        "退出登录",
                        JOptionPane.INFORMATION_MESSAGE);
                teacherMainFrame.showLoginFrame();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }

        });

    }


}